<template>
    <div>
        <el-form class="dataForm" label-width="100px">
            <el-form-item label="同步时间：">
                <el-date-picker
                    v-model="date"
                    type="datetimerange"
                    unlink-panels
                    start-placeholder="开始日期"
                    range-separator="至"
                    end-placeholder="结束日期">
                </el-date-picker>
                <el-button-group style="margin-left:15px">
                    <el-button type="success" @click="selectDate(1)" size="small">1 天</el-button>
                    <el-button type="primary" @click="selectDate(2)" size="small">2 天</el-button>
                    <el-button type="warning" @click="selectDate(3)" size="small">3 天</el-button>
                </el-button-group>
            </el-form-item>
        </el-form>
    </div>
</template>
<script>
export default {
    name:'syncOrder',
    data(){
        return{
            date:[],
        }
    },
    mounted(){
    	//默认初始化时选中一天
        this.date = []
        const end = new Date();
        const start = new Date();
        start.setTime(start.getTime() - 3600 * 1000 * 24 * 1);
        this.date.push(start)
        this.date.push(end)
    },
    methods:{
        // 选择时间快捷键
        selectDate(num){
            this.date = []
            const end = new Date();
            const start = new Date();
            start.setTime(start.getTime() - 3600 * 1000 * 24 * num);
            this.date.push(start)
            this.date.push(end)
        }
    }
}
</script>
